#pragma once
#include "VisioCommon.h"
#include "Meshes.h"
#include "ViewerCamera.h"
#include <opencv2/opencv.hpp>


struct SBoundingBox
{
	Vector3f Min;
	Vector3f Max;
};

class CMeshInstance
{
public:
	virtual void Draw() const = 0;
	virtual void Update(const float time, const CViewerCamera& Cam) = 0;
	virtual void DrawPicking() const {}
protected:
	CMesh* m_pMesh;
};

class CCameraMeshInstance : public CMeshInstance
{
public:
	CCameraMeshInstance(const Matrix4f& Rotate,const Matrix4f& translate, CCameraMesh* pMesh, char* ImageFileName, UINT Index);
	CCameraMeshInstance(const Matrix4f& Rotate,const Matrix4f& translate, CCameraMesh* pMesh, cv::Mat Image, UINT Index, float f);
	virtual void Draw() const;
	virtual void Update(const float time, const CViewerCamera& Cam);
	SBoundingBox GetWorldBoundingBox() const;
	void SetScale(float z);
	void SetColor(Vector3f col) {m_color = col;}
	virtual void DrawPicking() const;
private:
	void CommonInit(const Matrix4f& Rotate,const Matrix4f& translate, CCameraMesh* pMesh, float f);
	Matrix4f m_WVP;
	Matrix4f m_Scale;
	Matrix4f m_World;
	Vector3f m_color;
	Texture m_Image;
	UINT m_Index;
};

class CQuadMeshInstance : public CMeshInstance
{
public:
	CQuadMeshInstance(CQuadMesh* pMesh);
	virtual void Draw() const;
	virtual void Update(const float time, const CViewerCamera& Cam);
};

class CPointCloudMeshInstance : public CMeshInstance
{
public:
	CPointCloudMeshInstance(CPointCloudMesh* pMesh);
	virtual void Draw() const;
	virtual void Update(const float time, const CViewerCamera& Cam);
	SBoundingBox GetBoundingBox() const;
private:
	Matrix4f m_WVP;
};

class CPointOfInterestMeshInstance : public CMeshInstance
{
public:
	CPointOfInterestMeshInstance(Vector3f PointOfInterest);
	virtual void Draw() const;
	virtual void Update(const float time, const CViewerCamera& cam);
	SBoundingBox GetBoundingBox() const;
private:
	Matrix4f m_WVP;
};